package com.fitso.model.bean.measure.time;

import java.math.BigDecimal;
import java.text.DecimalFormat;

import org.apache.commons.lang.builder.CompareToBuilder;

import com.fitso.model.bean.measure.Measure;

/**
 * <p>
 * Base unit is {@link Second}.
 * </p>
 * 
 * @author timothystorm
 * 
 */
public abstract class Time extends Measure {
	private static final long serialVersionUID = 1L;
	
	public Time() {
		super();
	}
	
	public Time(Integer value){
		super(value);
	}
	
	public Time(Double value){
		super(value);
	}

	public Time(BigDecimal value) {
		super(value);
	}

	public Time(Time time) {
		convert(time);
	}

	public Time add(Integer time) {
		return (Time) super.add(time);
	}

	public Time add(Double time) {
		return (Time) super.add(time);
	}

	public Time add(Time time) {
		return (Time) super.add(time);
	}

	public Time convert(Time time) {
		return (Time) super.convert(time);
	}

	public Time divide(Integer time) {
		return (Time) super.divide(time);
	}

	public Time divide(Double time) {
		return (Time) super.divide(time);
	}

	public Time divide(Time time) {
		return (Time) super.divide(time);
	}

	public Time subtract(Integer time) {
		return (Time) super.subtract(time);
	}

	public Time subtract(Double time) {
		return (Time) super.subtract(time);
	}

	public Time subtract(Time time) {
		return (Time) super.subtract(time);
	}

	public Time multiply(Integer time) {
		return (Time) super.multiply(time);
	}

	public Time multiply(Double time) {
		return (Time) super.multiply(time);
	}

	public Time multiply(Time time) {
		return (Time) super.multiply(time);
	}

	public int compareTo(Time other) {
		return new CompareToBuilder().append(new Second(this), new Second(other)).toComparison();
	}

	protected Class<Time> getMeasure() {
		return Time.class;
	}

	public String toString() {
		return new DecimalFormat("#.00 " + getUnitMark()).format(getValue().doubleValue());
	}
}
